<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="org.jamwiki.model.*,org.jamwiki.*" %>   
<%
 String categoryName = request.getParameter("categoryName");
 String categoryId = request.getParameter("categoryId");
 List list = WikiBase.getDataHandler().getCateGoryByCategoryId(categoryId);
 int topicnum = WikiBase.getDataHandler().getTopocListByCategoryIdNum(categoryId);
 String message = null;
 boolean flag = false;
 if(list.size()>0){
	 message = "【" + categoryName + "】目录下已存在【"+list.size()+"】个子目录，不能删除";
 }else{
	 if(topicnum>0){
		 message = "【" + categoryName + "】目录下已存在【"+topicnum+"】个主题，不能删除";
	 } 
 }
 if(null == message){
	 WikiBase.getDataHandler().deleteCategory(categoryId);
	 message = "【" + categoryName + "】目录删除成功";
	 flag = true;
 }
%>
<script type="text/javascript">
<%if(message != null){%> 
  alert('<%=message%>');
  <%if(flag){%>
  opener.parent.location.reload();
 // opener.document.getElementById('categoryName').value="";
 // opener.document.getElementById('categoryId').value="";
  <%}%>
  window.close();
  <%}%>
</script>
